package model
{
	import utils.UtilTool;
	
	public class Userdata
	{
		public var version:String = "";
		private static var _instance:Userdata;
		
		public var userId:int;
		
		public var userAccount:String;
		
		public var userName:String;
		public var address:String;

		public var regdate:String;
		public var isLogin:Boolean = false;
		
		
		public var loginTime:Number = 0;
		
		public var sex:int = 0;
		
		public var birthday:String = "";
		
		public var curState:int = 1;//学习还是考试
	
		public var configVersion:String;

		public var curRandomStr:String;

		public static function get instance():Userdata
		{
			if(_instance == null)
				_instance = new Userdata();
			return _instance;
		}
		
		public function Userdata()
		{
			
		}
		
		public function resetData():void
		{
			isLogin = false;
			userAccount = "";
			userName = "";
			
		}
		
		public function selectUserCart(cartId:int):void
		{
			var defaultSelectGoods:String = UtilTool.getLocalVar("selectGoods","");
			var curdate:String = UtilTool.formatFullDateTime(new Date(),false);
			
			var hasSelectGoodsList:Array = [];
			if(defaultSelectGoods != "")
			{
				var selectGoods:Object = JSON.parse(defaultSelectGoods);
				if(selectGoods.date == curdate)
					hasSelectGoodsList = selectGoods.selectGoods;
			}
			
			if(hasSelectGoodsList.indexOf(cartId) < 0 )
			{
				hasSelectGoodsList.push(cartId);
			}
			
			
			
			var selectedObj:Object = {"date":curdate,"selectGoods":hasSelectGoodsList};
			UtilTool.setLocalVar("selectGoods",JSON.stringify(selectedObj));
		}
			
		
	}
}